// Package value implements the representation of Nix runtime values.
//
// Runtime values are broadly divided into user-facing Nix types
// (strings, numbers, attribute sets and so on), and internal values
// which should not be visible to users.
//
// Standard nix types are represented by the NixValue interface and
// eval APIs focus on returning only this type to users.
package value

import "context"

type NixValue interface {
	// NixType returns the human-readable type of a Nix value.
	NixType() string

	// String serialises the value to a string in the default Nix
	// format.
	String() string

	// Strict "deeply forces" the Nix value, so that it can be returned outside
	// of tvix without any unevaluated code remaining. The value may still
	// contain thunks, but they must be evaluated.
	Strict(context.Context) error
}

type Null struct{}

func (Null) NixType() string {
	return "null"
}

func (Null) String() string {
	return "null"
}

func (Null) Strict(context.Context) error {
	return nil
}

type Bool bool

func (Bool) NixType() string {
	return "bool"
}

func (b Bool) String() string {
	if bool(b) {
		return "true"
	} else {
		return "false"
	}
}

func (Bool) Strict(context.Context) error {
	return nil
}
